package com.mingke.db.Utils;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

import java.util.HashMap;
import java.util.Map;

@Configuration
@PropertySource(value = "classpath:yaohongGenerator.properties", encoding = "utf-8")
public class PropertiesReader {
    @Value("${basePackage}")
    public String basePackage;

    @Value("${dbPerfix}")
    public String dbPerfix;

    @Value("${author}")
    public String author;

    @Value("${selectSchema}")
    public String selectSchema;

    @Value("${mysql.varchar}")
    public String stringType;

    @Value("${mysql.int}")
    public String intType;

    @Value("${mysql.datetime}")
    public String dateType;

    @Value("${mysql.double}")
    public String doubleType;

    @Value("${filePath}")
    public String filePath;

    public String[] suffixs = {"Entity", "Mapper", "Service", "Controller"};

    public Map<String, String> mysqlTypes(){
        HashMap<String, String> result = new HashMap<>();
        result.put("varchar", stringType);
        result.put("int", intType);
        result.put("datetime", dateType);
        result.put("double", doubleType);
        return result;
    }

    /**
     * @function 首字母大写的函数
     * @param str
     * @return
     */
    public String capitalFirstLetter(String str){
        char[] cs=str.toCharArray();
        cs[0]-=32;
        return String.valueOf(cs);
    }

}
